from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from database import Session
import datetime
from dao import DaoWorkRecord,DaoSuperviseRecord


# 督办处理记录查询
class SuperviseRecordSelect(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
            bureauid = request.query_params["bureauid"]
            meter_barcode = request.query_params["meter_barcode"]
            return  DaoSuperviseRecord.get_supervise_info(session, bureauid, meter_barcode)
        finally:
            session.close()

class SuperviseRecordDetail(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
            bureauid = request.query_params["bureauid"]
            meter_barcode = request.query_params["meter_barcode"]
            serial_number = request.query_params["serial_number"]
            return DaoSuperviseRecord.get_supervise_detail(session, bureauid, meter_barcode, serial_number)
        finally:
            session.close()

class OperatorAssistRecord(HTTPEndpoint):
    #运维协助处理记录查询
    async def get(self, request):
        session = Session()
        try:
            bureauid = request.query_params["bureauid"]
            meter_barcode = request.query_params["meter_barcode"]
            serial_number_operation = request.query_params["serial_number_operation"]
            return DaoSuperviseRecord.get_supervise_station_detail(session, bureauid, meter_barcode, serial_number_operation)
        finally:
            session.close()